/**
 * VUEshop
 * ============================================================================
 * * 版权所有 2015-2027 深圳搜豹网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.vueshop.com.cn
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
 * 不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: soubao-java 2020-07-22 $
 */<template>
  <div>
    <div>
      <div class="fixed-bar">
        <div class="item-title">
          <router-link
            class="back"
            :to="{name:'reopen_list',params:{currentPage:$route.params.currentPage}}"
            title="返回列表"
          >
            <i class="fa fa-arrow-circle-o-left"></i>
          </router-link>
          <div class="subject">
            <h3>店铺等级管理 - 审核店铺等级</h3>
            <h5>网站系统店铺等级管理</h5>
          </div>
        </div>
      </div>
      <el-form ref="form" :model="form" label-width="200px">
        <el-form-item label="店铺名称：">{{form.re_store_name}}</el-form-item>
        <el-form-item label="等级名称：">{{form.re_grade_name}}</el-form-item>
        <el-form-item label="申请期限：">{{form.re_start_to_end_time_desc}}</el-form-item>
        <el-form-item label="申请时间：">{{form.re_create_time_desc}}</el-form-item>
        <el-form-item label="续费时长：">{{form.re_year}} 年</el-form-item>
        <el-form-item label="收费标准：">{{form.re_grade_price | toFixed}} 元/年</el-form-item>
        <el-form-item label="应付总额：">{{form.re_pay_amount | toFixed}}</el-form-item>
        <el-form-item label="支付凭证：">
          <img
            v-if="form.re_pay_cert"
            :src="form.re_pay_cert"
            class="avatar"
            style="width: 300px; height: 200px"
          />
        </el-form-item>
        <el-form-item label="付款凭证说明：">{{form.re_pay_cert_explain}}</el-form-item>
        <el-form-item label="审核备注：">
          <el-input type="textarea" v-model="form.admin_note" style="width:350px"></el-input>
        </el-form-item>
        <el-form-item label="审核：" v-if="state == 1">
          <el-switch
            v-model="form.re_state"
            active-value="2"
            inactive-value="-1"
            active-text="通过"
            inactive-text="拒绝"
          ></el-switch>
        </el-form-item>
        <el-form-item label="审核状态：" v-else>
          <span>{{form.re_state_desc}}</span>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确认提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import {getStoreReopen,updateStoreReopen} from "@/utils/api";
export default {
  data() {
    return {
      form: {},
      goods_category_tree: [],
      category: [],
      state: 0
    };
  },
  created() {
    if (this.$route.params.id) {
      this.getReopen();
    }
  },
  methods: {
    getReopen() {
      var that = this;
	  getStoreReopen({
		  re_id: this.$route.params.id
	  })
	  .then(function(res) {
	    that.state = res.re_state;
	    that.re_state = String(res.re_state);
	    that.form = res;
	  });
    },
    onSubmit() {
      var that = this;
	  updateStoreReopen(that.form)
	  .then(function(res) {
	    if (res.msg) {
	      that.$message.error(res.msg);
	    } else {
	      that.$message({
	        message: "保存成功",
	        type: "success",
	        onClose: function() {
	          that.$router.push({ name: "reopen_list" });
	        }
	      });
	    }
	  });
    }
  },
  filters: {
    toFixed(value) {
      if (typeof value == "number") {
        return value.toFixed(2);
      } else {
        return value;
      }
    }
  }
};
</script>

<style scoped>
</style>
